package com.baosight.sczx.common.zm.cInterface.cb;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.zm.cb.domain.ZMCBWorkingface;

/**
 * 采面 对外接口
 * <p>Title: Mine.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 高强
 * @version 1.0
 * <pre>Histroy:
 *          2013-7-3 上午11:01:49  高强 
 *</pre>
 */
public class Workingface {

	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	/**
	 * 矿井建模 中用到的采面
	 * <p>Function: getWorkingface</p>
	 * <p>Description: </p>
	 * <p>return value:List<Map></p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *   2013-7-3 上午11:01:49  高强 
	 * </p>
	 *
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static List<Map> getWorkingface(Map<String, String> _argMap){
		_argMap = _argMap == null ? new HashMap<String, String>():_argMap;
		List<Map>  _list = new ArrayList();
		try {
			_list = dao.query("ZMCBWorkingface.queryTree", _argMap);
		} catch (Exception e) {
			
		}
		return _list;
	}
	
	/**构造相对采面名称block
	 * <p>Function: getNeighboringWorkingFaceBlock</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCB01</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-06-21下午15:31:29  梁琦
	 * </p>
	 *
	*/
	@SuppressWarnings({ "rawtypes", "unchecked"})
	public static EiBlock getNeighboringWorkingFaceBlock(String keyID)
	{
		EiBlock block = new EiBlock("cmes.cb.NeighboringWorkingFaceName");

		
		EiColumn eiColumn = new EiColumn("fdKeyId");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdName");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		Map<String, String> _map = new HashMap<String, String>();
		_map.put("fdNoKeyId", keyID);
		List<Map>  roadWayList = dao.query("ZMCBWorkingface.queryName", _map);//采面
		
		block.addRows(roadWayList);
		return block;
	}
	
	/**构造采面名称block
	 * <p>Function: getWorkingFaceBlock</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCB01</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-06-21下午15:31:29  梁琦
	 * </p>
	 *
	*/
	@SuppressWarnings({ "rawtypes", "unchecked"})
	public static EiBlock getWorkingFaceBlock()
	{
		EiBlock block = new EiBlock("cmes.cb.WorkingFaceName");

		
		EiColumn eiColumn = new EiColumn("fdKeyId");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdName");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdLength");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdStatus");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdSurplusToLength");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdHeight");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdWidth");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdSurplusReserves");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdManufacturability");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
				
		block.addRows(getList());
		return block;
	}
	
	/**
	 * 获取采面(开采和设计)
	 * <p>Function: getList</p>
	 * <p>Description: </p>
	 * <p>return value:List<Map></p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-8-26上午09:37:02 张志芳
	 * </p>
	 * 
	 */
	public static List<Map> getList(){
		Map<String, String> _map = new HashMap<String, String>();
		_map.put("notComplete", "yes");
		return dao.query("ZMCBWorkingface.queryName", _map);//采面		
	}
	
	/**
	 * 获取开工的采面
	 * <p>Function: getWorkingList</p>
	 * <p>Description: </p>
	 * <p>return value:List<Map></p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-9-21上午06:07:26 张志芳
	 * </p>
	 *
	 */
	public static List<Map> getWorkingList(){
		Map<String, String> _map = new HashMap<String, String>();
		_map.put("fdStatus", "开工");
		return dao.query("ZMCBWorkingface.queryName", _map);	
	}
	
	/**
	 * 获取设计的采面
	 * <p>Function: getDesignList</p>
	 * <p>Description: </p>
	 * <p>return value:List<Map></p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-9-21上午06:07:38 张志芳
	 * </p>
	 *
	 */
	public static List<Map> getDesignList(){
		Map<String, String> _map = new HashMap<String, String>();
		_map.put("fdStatus", "设计");
		return dao.query("ZMCBWorkingface.queryName", _map);	
	}
	
	/**
	 * 根据采区ID获取其下的首采面ID
	 * <p>Function: getFirstWorkface</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-9-16上午06:50:48 张志芳
	 * </p>
	 *
	 */
	public static String getFirstWorkface(String araeId){
		String wf = "";
		Map map = new HashMap();
		map.put("fdParentId", araeId);
		map.put("fdIsFirst", "是");
		List<Map> list = dao.query("ZMCBWorkingface.queryName", map);
		if(list.size()>0){
			wf = (String)list.get(0).get("fdKeyId");
		}
		return wf;
	}
	
	/**
	 * 判断是否是首采面
	 * <p>Function: isFirst</p>
	 * <p>Description: </p>
	 * <p>return value:Boolean</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-9-21下午03:50:28 张志芳
	 * </p>
	 *
	 */
	public static Boolean isFirst(String workfaceId){
		Map map = new HashMap();
		map.put("fdKeyId", workfaceId);
		map.put("fdIsFirst", "是");
		List<Map> list = dao.query("ZMCBWorkingface.queryName", map);
		if(list.size()>0){
			return true;
		}
		return false;
	}
}
